
var vm =  new Vue({
    el : "#app",
    data : {
        code_show:false,
        yz_code:'获取验证码',
        yz_time:60,
        regis_tel:'',
        pass_word_one:'',
        pass_word_two:'',
        levelName:'',//会员等级
        userName:'',//会员名
        yz_tel_code:'',//验证码
        reset_show:false
    },
    created:function(){
        this.levelName = _lSGet('levelName');//会员等级
        this.userName = _lSGet('userName');//userName
        if(!this.levelName){
            _lSSaveOrUpdate( 'forwordPage','/app/me-message.html');//记录当前页
            window.location.href=backUrl;//没会员信息就跳转到首页
        }
    }
    ,
    mounted:function(){


    },
    methods:{

        go_history_order:function(){//我的订单
           // router.push('/go_history_order');
            window.location.href=indexUrl+'/app/history-order.html?_t=' + Math.random() ;
        },
        yzTelNumber: function (userTelNum) {
            var that = this;
            if (!userTelNum) {
                tips('电话号码不能为空');
            }else if (!(/^1[34578]\d{9}$/.test(userTelNum))) {
                tips('电话号码格式错误');
            }
        },
        go_reset_pass:function(){
            this.reset_show=true;
        },
        quit:function(){//退出登录
            localStorage.clear();//清空所有localStorage数据
            WeixinJSBridge.call('closeWindow');//关闭页面并跳到公众号首页


        },
        //reset_ok:function(){//完成并登录
        //    this.reset_show=false;
        //
        //},
        reset_ok:function(){//type类型3，重置密码并登录
            this.reset_show=false;
            if (!(/^1[34578]\d{9}$/.test(this.regis_tel))){
                tips('手机号格式不正确');
                return;
            }
            if(this.pass_word_one!=this.pass_word_two){
                tips('两次密码输入不相同，请重新输入');
                return;
            }else{
                var params = {};
                params.mobile = this.regis_tel;
                params.password = this.pass_word_one;
                params.confirmPassword = this.pass_word_one;//和上面一样
                params.verificationCode = this.yz_tel_code;//验证码

                var that=this;
                sendRequest('/forgetPassword/changePassword', params, function(res) {
                    console.log('kkkkk');
                    console.log(res);
                    if(res.status==1){
                        //_lSSaveOrUpdate( 'token', res.data.opInfo.token );
                        //_lSSaveOrUpdate( 'openId', res.data.opInfo.openId );
                        //_lSSaveOrUpdate( 'userId', res.data.opInfo.userId );
                        //_lSSaveOrUpdate( 'userName', res.data.opInfo.userName );
                        var paramss = {};
                        paramss.mobile = params.mobile;
                        paramss.password =   params.password;
                        sendRequest('/wxLogin/pwdLogin', paramss, function(res) {//登录
                            console.log('opop');
                            console.log(res);
                            if(res.status==1){
                                _lSSaveOrUpdate( 'token', res.data.opInfo.token );
                                _lSSaveOrUpdate( 'openId', res.data.opInfo.openId );
                                _lSSaveOrUpdate( 'userId', res.data.opInfo.userId );
                                _lSSaveOrUpdate( 'levelName', res.data.opInfo.levelName );//会员等级
                                _lSSaveOrUpdate( 'userName', res.data.opInfo.userName );//会员名
                                _lSSaveOrUpdate( 'userName', res.data.opInfo.userName );
                                //var pp=  _lSGet('token');
                                //console.log(pp);
                                window.location.href=indexUrl+'/index.html?_t=' + Math.random();
                            }
                            //if(res.status==-1){
                            //    tips(res.returnMsg);
                            //}
                        });
                        //window.location.href=indexUrl+'/index.html?_t=' + Math.random();
                    }
                    if(res.status==-1){
                        tips(res.returnMsg);
                    }
                });
            }
        },
        get_code:function(){
            this.yzTelNumber(this.regis_tel);
            var that=this;
            if (that.regis_tel && (/^1[34578]\d{9}$/.test(that.regis_tel))){//输入手机号格式正确
                that.yz_code = "剩余" + that.yz_time + "秒";
                that.code_show=true;
                var timer = setInterval(function () {
                    var time = that.yz_time - 1;
                    if (that.yz_time > 1) {
                        that.yz_time =time,
                            that.yz_code = "剩余" + time + "秒"
                    } else {
                        clearInterval(timer);//清除定时器
                        that.yz_time = 60,
                            that.code_show=false;
                        that.yz_code = "获取验证码"
                    }
                }, 1000);
                //发送请求
                var params = {};
                params.mobile=that.regis_tel;
                params.type=3;//1,登录  2,注册 3,找回密码(重置修改密码)
                sendRequest('/pinCode/send',params , function(res) {//发送验证码
                    //console.log('opop')
                    console.log(res);
                    tips(res.returnMsg)
                    //if(res.status=1){
                    //
                    //  }
                });

            }
        }

    },
    computed: {

    },
    watch:{

    },

    components:{


    }


});